/* file to explain this pointer */ #include using namespace std; struct nd{ nd():n(0),d(0){} nd(int a, int b):n(a), d(b){} int n; int d; }; class rat{ public: nd *pnd; rat():pnd(new nd()){} rat(int a, int b):pnd(new nd(a,b)){} rat(rat&r){ pnd = new nd(r.pnd->n,r.pnd->d); } rat& operator=(rat rhs){ if(&rhs!=this){ cout << "in assignment operator"<pnd->n << " " << this->pnd->d << endl; cout << rhs.pnd->n << " " << rhs.pnd->d << endl; pnd->n = rhs.pnd->n; pnd->d = rhs.pnd->d; } return *this; } ~rat(){delete pnd;} }; void main(){ rat x(1,2), y(14,77); rat p(99,98), q(-4,14); y = x = q; p = q; q = q; }